{% extends "layout.html" %} 
{% block content %}
  <fieldset class="layui-elem-field layui-field-title">
    <legend>新增用户使用ModelForm</legend>
  </fieldset>
  <form class="layui-form" method="post" action="/user/model/form/add/" novalidate autocomplete="off">
    {% csrf_token %}
<!--      {{form}}-->
<!--      <hr />-->
<!--      {{form.name.label}}：{{form.name}}-->
<!--      {{form.password.label}}：{{form.password}}-->
<!--      {{form.age.label}}：{{form.age}}-->
<!--      <hr />-->
<!--      {% for field in form %}-->
<!--        {{field.label}} : {{field}}-->
<!--      {% endfor %}-->
      {% for field in form %}
      <div class="layui-form-item">
        <label class="layui-form-label">{{field.label}}</label>
        <div class="layui-input-block">
          {{field}}
          <span class="layui-font-red">
            {{field.errors.0}}
          </span>
<!--          <input type="text" name="name" lay-verify="required" placeholder="请输入姓名" autocomplete="off" class="layui-input">-->
        </div>
      </div>
      {% endfor %}
    <div class="layui-input-block">
      <button type="submit" class="layui-btn" lay-submit lay-filter="demo1">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </form>
{% endblock %}
{% block js %}
<script>
layui.use(['laydate'], function(){
  var laydate = layui.laydate;
  //执行一个laydate实例
  laydate.render({
    elem: '#LayDate-CreateTime', //指定元素
    type: 'date',
    trigger: 'click', //采用click弹出
    format: 'yyyy-MM-dd', //日期时间格式
    value: '{{ form.instance.create_time|date:"Y-m-d" }}' //设置默认值
  });
});
</script>
{% endblock %}